//# sourceURL=bigscreen.js
/**
 * Created by lhassy on 2016/12/28.
 */
var bigscreen = function () {

    var setIntervalID = 0;
    var fontcolor = "white";

    function GetET() {
        $.ajax({
            type: "POST",
            url: backServerUrl + "api/auth/token",
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            success: function (data) {

            },
            error: function () {

            }
        });
    }
    //借书排行榜 3
    function BorrowCount() {
        var myChart2 = echarts.init(document.getElementById('chartborrow'));
        option = {
            title:{
                text:"借阅排行榜",
                textStyle:{
                   color:"#64879c" 
                }
                
            },
            legend: {
                data:['借阅次数'],
                show:false
            },
            tooltip : {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            xAxis : {
                type : 'category',
                boundaryGap : false,
                // axisLabel: {
                //     textStyle: {
                //         color: '#FFFFFF'
                //     }
                // },
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置x轴颜色
                    }
                },
                data : ['三国演义','小王子','伊索寓言','红楼梦','一千零一夜','水浒传','中华上下五千年']
            },
            yAxis : {
                type : 'value',
                name:'借阅次数',
                // axisLabel: {
                //     textStyle: {
                //         color: '#FFFFFF'
                //     }
                // },
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置x轴颜色
                    }
                },
            },
            series : [
                {
                    name:'借阅次数',
                    type:'line',
                    stack: '总量',
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    },
                    itemStyle:{
                        normal:{
                            // color:"rgb(26,64,84)"
                            color:"#4fc0f5"
                        }
                    },
                    lineStyle:{
                        normal:{color:"#4fc0f5"}
                    },
                    areaStyle: {
                        normal: {color:"#0c4c7c"},
                        shadowColor:'#4fc0f5'
                    },
                    data:[230,210, 132, 134,120,101, 90 ]
                }
            ]
        };

        myChart2.setOption(option);
        window.onresize = myChart2.resize;
    }
    //读者排行榜
    function ReaderCount() {
        var et = window.localStorage["et"];
        var backServerUrl = window.localStorage["backServerUrl"];
        var startTime = "2016-07-11";
        var endTime = "2016-08-20";
        var limit = 10;
        $.ajax({
            type: "get",
            url: backServerUrl + "api/statistics/jh?start=" + startTime + "T00:00:01.001&end=" + endTime + "T23:59:59.001&interval=1m&top=" + limit + "&device_alias=&source=false&aggregation=operation__reader_name",
            dataType: "json",
            headers: {'Content-Type': 'application/json', 'Authorization': et},
            beforeSend: function(){
                // $("#countreportbutton").addClass("breath_light");
            },
            complete: function(){
                // $("#countreportbutton").removeClass("breath_light");
            },
            success: function (data) {
                var tableCount = "";
                var bu = null;

                //按读者
                var xCategories = [];
                var borrowData = [];

                    for (var i in data.aggregations.operation.buckets) {
                        if (data.aggregations.operation.buckets[i].key === "borrow")
                            bu = data.aggregations.operation.buckets[i].reader_id.buckets;
                    }
                    if (bu == null) {
                        alert("该段时间内没有数据!");
                        return;
                    }
                    for (var i in bu) {
                        xCategories.push(bu[i].reader_name.hits.hits[0]._source.reader_name);
                        borrowData.push(bu[i].doc_count);
                    }

                //按读者
                $('#chartreader').highcharts({
                    colors: ['#4568D9', '#7FB451', '#DDDF00'],
                    chart: {
                        type: 'column',
                        // options3d: {
                        //     enabled: true,
                        //     alpha: 2,
                        //     beta: 2,
                        //     viewDistance: 25,
                        //     depth: 20
                        // },
                        backgroundColor: 'rgba(0,0,0,0)'
                    },
                    credits: {
                        enabled: false
                    },
                    title: {
                        text: '读者排行榜',
                        style:{
                            'fontSize':'18px',
                            'color':fontcolor
                        }
                    },
                    legend:{
                        enabled : false
                    },
                    exporting: { enabled: false },
                    xAxis: {
                        categories: xCategories,
                        labels:{
                            style:{
                                'color':fontcolor
                            }
                        }
                    },
                    yAxis: {
                        allowDecimals: false,
                        title: {
                            text: '借阅次数',
                            style:{
                                'fontSize':'18px',
                                'color':fontcolor
                            }
                        },
                        labels:{
                            style:{
                                'color':fontcolor
                            }
                        }
                    },
                    plotOptions: {
                        series: {
                            borderWidth: 0,
                            colorByPoint: true,
                            dataLabels: {
                                enabled: true,
                                format: '{point.y}',
                                style:{
                                    'color':fontcolor
                                }
                            }
                        }
                    },
                    // exporting: { enabled: false },
                    series: [{
                        name: '借阅次数',
                        data: borrowData
                    }]
                });
            }
        });
    }
    //借书还书柱状图 5
    function BRDisplay() {
        var myChart1 = echarts.init(document.getElementById('chartreader'));
        var xAxisData = [];
        var data1 = [];
        var data2 = [];
        
        for (var i = 0; i < 24; i++) {
            xAxisData.push(i+":00");
            data1.push((Math.random() * 2).toFixed(2));
            data2.push(-Math.random().toFixed(2));
        }

        var itemStyle = {
            normal: {
                color:"#4fc0f5",
                label:{
                    show:true
                }
            },
            emphasis: {
                barBorderWidth: 1,
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowOffsetY: 0,
                shadowColor: 'rgba(0,0,0,0.5)'
            }
        };

        var itemStyle1 = {
            normal: {
                color:"#0c4c7c",
                label:{
                    show:true
                }
            },
            emphasis: {
                barBorderWidth: 1,
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowOffsetY: 0,
                shadowColor: 'rgba(0,0,0,0.5)'
            }
        };

        option = {
            title: {
                text: '借还书',
                textStyle:{
                    color:"#64879c"
                }
            },
            // backgroundColor: '#eee',
            legend: {
                data: ['借书数量', '还书数量'],
                bottom: 0,
                textStyle:{
                    color:"#FFFFFF"
                }
            },
            tooltip : {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            grid:{
                show:true
            },
            xAxis: {
                data: xAxisData,
                name: 'X Axis',
                silent: false,
                axisLine: {onZero: true},
                splitLine: {show: false},
                splitArea: {show: false},
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置x轴颜色
                    }
                },
                axisLabel:{
                    rotate: 40,
                    interval:'0',
                    // textStyle:{
                    //     color:'#FFFFFF'
                    // }
                },
            },
            yAxis: {
                splitArea: {show: false},
                // axisLabel: {
                //     textStyle: {
                //         color: '#FFFFFF'
                //     }
                // },
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置x轴颜色
                    }
                },
                // axisLine:{
                //     show:false
                // },
            },
            grid: {
                left: 30
            },
            series: [
                {
                    name: '借书数量',
                    type: 'bar',
                    stack: 'one',
                    itemStyle: itemStyle,
                    data: data1,
                },
                {
                    name: '还书数量',
                    type: 'bar',
                    stack: 'one',
                    itemStyle: itemStyle1,
                    data: data2
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart1.setOption(option);
    }

    //出入馆 5
    function BRDisplay2() {
        var myChart5 = echarts.init(document.getElementById('entrance'));
        var xAxisData = [];
        for (var i = 0; i < 24; i++) {
            xAxisData.push(i+":00");
        }

        option = {
            title: {
                text: '实时出入馆数据',
                textStyle:{
                    color:"#64879c"
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            legend: {
                data:['入馆人次','出馆人次','在馆人数'],
                textStyle: {
                    color: '#fff'
                },
                top: 'bottom',
                left: 'center'
            },
            xAxis: [
                {
                    type: 'category',
                    data: xAxisData,
                    axisPointer: {
                        type: 'shadow'
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#95a7c5'//设置x轴颜色
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '入馆/出馆',
                    min: 0,
                    max: 250,
                    interval: 50,
                    axisLabel: {
                        formatter: '{value}'
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#95a7c5'//设置图形右侧颜色
                        }
                    }
                },
                {
                    type: 'value',
                    name: '在馆',
                    min: 0,
                    max: 25,
                    interval: 5,
                    axisLine: {
                        lineStyle: {
                            color: '#95a7c5'//设置图形右侧颜色
                        }
                    },
                    axisLabel: {
                        formatter: '{value}'
                    }
                }
            ],
            series: [
                {
                    name:'入馆人次',
                    type:'bar',
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    },
                    itemStyle:{
                        normal:{
                            color:"#4fc0f5"
                        }
                    },
                    data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3,2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
                },
                {
                    name:'出馆人次',
                    type:'bar',
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    },
                    itemStyle:{
                        normal:{
                            color:"#0c4c7c"
                        }
                    },
                    data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3,2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
                },
                {
                    name:'在馆人数',
                    type:'line',
                    smooth: true,
                    yAxisIndex: 1,
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    },
                    itemStyle:{
                        normal:{
                            color:"#4fc0f5"
                        }
                    },
                    data:[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2,2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
                }
            ]
        };
        myChart5.setOption(option);
    }

    //出入馆 5
    function borrow() {
        var myChart6 = echarts.init(document.getElementById('borrow'));
        
        var hours = ['0', '1', '2', '3', '4', '5', '6',
                '7', '8', '9','10','11',
                '12', '13', '14', '15', '16', '17',
                '18', '19', '20', '21', '22', '23'];
        var days = ['0', '10 ', '20',
                '30', '40', '50', '60'];

        var data = [[0,0,5,"书名demo1"],[0,1,1,"书名demo2"],[0,2,0,"书名demo3"],[0,3,0,"书名demo"],[0,4,0,"书名demo"],[0,5,0,"书名demo"],[0,6,0,"书名demo4"],[0,7,0,"书名demo"],[0,8,0,"书名demo8"],[0,9,0,"书名demo"],[0,10,0,"书名demo"],[0,11,2,"书名demo"],[0,12,4,"书名demo"],[0,13,1,"书名demo"],[0,14,1,"书名demo"],[0,15,3,"书名demo"],[0,16,4,"书名demo"],[0,17,6,"书名demo"],[0,18,4,"书名demo"],[0,19,4,"书名demo"],[0,20,3,"书名demo"],[0,21,3,"书名demo"],[0,22,2,"书名demo"],[0,23,5,"书名demo"],[1,0,7,"书名demo"],[1,1,0,"书名demo"],[1,2,0,"书名demo"],[1,3,0,"书名demo"],[1,4,0,"书名demo"],[1,5,0,"书名demo"],[1,6,0,"书名demo"],[1,7,0,"书名demo"],[1,8,0,"书名demo"],[1,9,0,"书名demo"],[1,10,5,"书名demo"],[1,11,2,"书名demo"],[1,12,2,"书名demo"],[1,13,6,"书名demo"],[1,14,9,"书名demo"],[1,15,11,"书名demo"],[1,16,6,"书名demo"],[1,17,7,"书名demo"],[1,18,8,"书名demo"],[1,19,12,"书名demo"],[1,20,5,"书名demo"],[1,21,5,"书名demo"],[1,22,7,"书名demo"],[1,23,2,"书名demo"],[2,0,1,"书名demo"],[2,1,1,"书名demo"],[2,2,0,"书名demo"],[2,3,0,"书名demo"],[2,4,0,"书名demo"],[2,5,0,"书名demo"],[2,6,0,"书名demo"],[2,7,0,"书名demo"],[2,8,0,"书名demo"],[2,9,0,"书名demo"],[2,10,3,"书名demo"],[2,11,2,"书名demo"],[2,12,1,"书名demo"],[2,13,9,"书名demo"],[2,14,8,"书名demo"],[2,15,10,"书名demo"],[2,16,6,"书名demo"],[2,17,5,"书名demo"],[2,18,5,"书名demo"],[2,19,5,"书名demo"],[2,20,7,"书名demo"],[2,21,4,"书名demo"],[2,22,2,"书名demo"],[2,23,4,"书名demo"],[3,0,7,"书名demo"],[3,1,3,"书名demo"],[3,2,0,"书名demo"],[3,3,0,"书名demo"],[3,4,0,"书名demo"],[3,5,0,"书名demo"],[3,6,0,"书名demo"],[3,7,0,"书名demo"],[3,8,1,"书名demo"],[3,9,0,"书名demo"],[3,10,5,"书名demo"],[3,11,4,"书名demo"],[3,12,7,"书名demo"],[3,13,14,"书名demo"],[3,14,13,"书名demo"],[3,15,12,"书名demo"],[3,16,9,"书名demo"],[3,17,5,"书名demo"],[3,18,5,"书名demo"],[3,19,10,"书名demo"],[3,20,6,"书名demo"],[3,21,4,"书名demo"],[3,22,4,"书名demo"],[3,23,1,"书名demo"],[4,0,1,"书名demo"],[4,1,3,"书名demo"],[4,2,0,"书名demo"],[4,3,0,"书名demo"],[4,4,0,"书名demo"],[4,5,1,"书名demo"],[4,6,0,"书名demo"],[4,7,0,"书名demo"],[4,8,0,"书名demo"],[4,9,2,"书名demo"],[4,10,4,"书名demo"],[4,11,4,"书名demo"],[4,12,2,"书名demo"],[4,13,4,"书名demo"],[4,14,4,"书名demo"],[4,15,14,"书名demo"],[4,16,12,"书名demo"],[4,17,1,"书名demo"],[4,18,8,"书名demo"],[4,19,5,"书名demo"],[4,20,3,"书名demo"],[4,21,7,"书名demo"],[4,22,3,"书名demo"],[4,23,0,"书名demo"],[5,0,2,"书名demo"],[5,1,1,"书名demo"],[5,2,0,"书名demo"],[5,3,3,"书名demo"],[5,4,0,"书名demo"],[5,5,0,"书名demo"],[5,6,0,"书名demo"],[5,7,0,"书名demo"],[5,8,2,"书名demo"],[5,9,0,"书名demo"],[5,10,4,"书名demo"],[5,11,1,"书名demo"],[5,12,5,"书名demo"],[5,13,10,"书名demo"],[5,14,5,"书名demo"],[5,15,7,"书名demo"],[5,16,11,"书名demo"],[5,17,6,"书名demo"],[5,18,0,"书名demo"],[5,19,5,"书名demo"],[5,20,3,"书名demo"],[5,21,4,"书名demo"],[5,22,2,"书名demo"],[5,23,0,"书名demo"],[6,0,1,"书名demo"],[6,1,0,"书名demo"],[6,2,0,"书名demo"],[6,3,0,"书名demo"],[6,4,0,"书名demo"],[6,5,0,"书名demo"],[6,6,0,"书名demo"],[6,7,0,"书名demo"],[6,8,0,"书名demo"],[6,9,0,"书名demo"],[6,10,1,"书名demo"],[6,11,0,"书名demo"],[6,12,2,"书名demo"],[6,13,1,"书名demo"],[6,14,3,"书名demo"],[6,15,4,"书名demo"],[6,16,0,"书名demo"],[6,17,0,"书名demo"],[6,18,0,"书名demo"],[6,19,0,"书名demo"],[6,20,1,"书名demo"],[6,21,2,"书名demo"],[6,22,2,"书名demo"],[6,23,6,"书名demo"]];
        option = {
            title: {
                text: '实时借阅数据',
                textStyle:{
                    color:"#64879c"
                }
            },
            legend: {
                data: ['借阅数据'],
                left: 'right',
                textStyle:{
                    color:"#64879c"
                }
            },
            polar: {},
            tooltip: {
                formatter: function (params) {
                    return hours[params.value[1]] + ":" + days[params.value[0]] + params.value[3];
                }
            },
            angleAxis: {
                type: 'category',
                data: hours,
                boundaryGap: false,
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#999',
                        type: 'dashed'
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置图形右侧颜色
                    },
                    show: false
                }
                // axisLine: {
                //     show: false
                // }
            },
            radiusAxis: {
                type: 'category',
                data: days,
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置图形右侧颜色
                    },
                    show: false
                },
                axisLabel: {
                    rotate: 45
                }
            },
            series: [{
                name: '借阅数据',
                type: 'scatter',
                coordinateSystem: 'polar',
                symbolSize: function (val) {
                    return val[2] * 2;
                },
                label: {
                    normal:{
                        show:true,
                        formatter:function(param){
                            var myDate = new Date();
                            var h=myDate.getHours();
                            if(hours[param.value[1]]==h)
                                return param.value[3] 
                            else 
                                return ""   
                        }
                    }
                },
                itemStyle:{
                    normal:{
                        color:"#4fc0f5"
                    }
                },
                data: data,
                animationDelay: function (idx) {
                    return idx * 5;
                }
            }]
        };
        myChart6.setOption(option);
    }
    //借还总册次 6
    function BRCount() {
        var et = window.localStorage["et"];
        var backServerUrl = window.localStorage["backServerUrl"];
        var now = new Date().format("yyyy-MM-dd");
        var startTime = "2017-01-01";
        var endTime = now;
        var interval = "1y";
        $.ajax({
            type: "get",
            url: backServerUrl + "api/statistics/jh?start=" + startTime + "T00:00:00.001&end=" + endTime + "T23:59:59.001&interval=" + interval + "&device_alias=&source=false&aggregation=operation__datetime",
            dataType: "json",
            headers: {'Content-Type': 'application/json','Authorization':et},
            success: function (data) {
                var tableCount = "";
                var sfdata = null;
                var dhdata = "";
                var xCategories = [];
                var returnData = [];
                var borrowData = [];
                var renewData = [];
                var countDeviceHeader = "";
                var bu = data.aggregations.operation.buckets;

                if (bu.length > 0) {
                    var jh = "";
                    var jhstime = "";
                    var jhetime = "";
                    for (var i in bu[0].datetime.buckets) {
                        var tdataBorrow = "";
                        var tdataReturn = "";
                        var tdataRenew = "";
                        var countBorrow = 0;
                        var countReturn = 0;
                        for (var j = 0; j < bu.length; j++) {
                            switch (bu[j].key){
                                case "borrow":
                                    // borrowData.push(bu[j].datetime.buckets[i].doc_count);
                                    countBorrow += bu[j].datetime.buckets[i].doc_count;
                                    // tdataBorrow = "<td style='text-align: right;'><a href='javascript:void(0);' onclick='DisplayJHDetails(\"" + jhstime + "\",\"" + jhetime + "\",\"" + selectedDevice + "\",\"\",\"\",\"" + bu[j].key + "\",\"\");'>" + bu[j].datetime.buckets[i].doc_count + "</a></td>";
                                    break;
                                case "return":
                                    // returnData.push(-bu[j].datetime.buckets[i].doc_count);
                                    countReturn += bu[j].datetime.buckets[i].doc_count;
                                    // tdataReturn = "<td style='text-align: right;'><a href='javascript:void(0);' onclick='DisplayJHDetails(\"" + jhstime + "\",\"" + jhetime + "\",\"" + selectedDevice + "\",\"\",\"\",\"" + bu[j].key + "\",\"\");'>" + bu[j].datetime.buckets[i].doc_count + "</a></td>";
                                    break;
                                case "renew":
                                    // renewData.push(bu[j].datetime.buckets[i].doc_count);
                                    // tdataRenew = "<td style='text-align: right;'><a href='javascript:void(0);' onclick='DisplayJHDetails(\"" + jhstime + "\",\"" + jhetime + "\",\"" + selectedDevice + "\",\"\",\"\",\"" + bu[j].key + "\",\"\");'>" + bu[j].datetime.buckets[i].doc_count + "</a></td>";
                                    break;
                            }
                        }
                    }
                    $(".countborrow").html(countBorrow);
                    $(".countreturn").html(countReturn);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //当前状态(readyState),0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成
                alert("PaperCount 请求产生错误!\n" + "status = " + XMLHttpRequest.status + "\nstatusText = " + XMLHttpRequest.statusText + "\nreadyState = " + XMLHttpRequest.readyState + "\nresponseText = " + XMLHttpRequest.responseText);
            }
        });
    }

    //出入馆 5
    function InforShow() {
        var myChart7 = echarts.init(document.getElementById('infor'));
        
        option = {
            tooltip : {
                formatter: "{a} <br/>{c}"
            },
            series : [
                {
                    name:'入馆人数',
                    type:'gauge',
                    min:0,
                    max:33000,
                    splitNumber:11,
                    radius: '50%',
                    axisLine: {            // 坐标轴线
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: [[0.09, 'lime'],[0.82, '#1e90ff'],[1, '#ff4500']],
                            width: 3,
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisLabel: {            // 坐标轴小标记
                        textStyle: {       // 属性lineStyle控制线条样式
                            fontWeight: 'bolder',
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisTick: {            // 坐标轴小标记
                        length :15,        // 属性length控制线长
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: 'auto',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    splitLine: {           // 分隔线
                        length :25,         // 属性length控制线长
                        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                            width:3,
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    pointer: {           // 分隔线
                        shadowColor : '#fff', //默认透明
                        shadowBlur: 5
                    },
                    title : {
                        offsetCenter: [0, '-140%'],
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            // fontWeight: 'bolder',
                            fontSize: 60,
                            fontStyle: 'italic',
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10,
                            fontSize: 40
                        }
                    },
                    detail : {
                        // backgroundColor: 'rgba(30,144,255,0.8)',
                        // borderWidth: 1,
                        // borderColor: '#fff',
                        // shadowColor : '#fff', //默认透明
                        shadowBlur: 5,
                        offsetCenter: [0, '90%'],       // x, y，单位px
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            fontWeight: 'bolder',
                            color: '#acff48',
                            fontSize: 70
                        }
                    },
                    data:[{value: 3000, name: '入馆人数'}]
                },
                {
                    name:'借书总量',
                    type:'gauge',
                    center : ['22%', '50%'],    // 默认全局居中
                    radius : '40%',//控制大小
                    endAngle:60,
                    min:0,
                    max:700,
                    splitNumber:7,
                    axisLine: {            // 坐标轴线
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: [[0.29, 'lime'],[0.86, '#1e90ff'],[1, '#ff4500']],
                            width: 2,
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisLabel: {            // 坐标轴小标记
                        textStyle: {       // 属性lineStyle控制线条样式
                            fontWeight: 'bolder',
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisTick: {            // 坐标轴小标记
                        length :12,        // 属性length控制线长
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: 'auto',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    splitLine: {           // 分隔线
                        length :20,         // 属性length控制线长
                        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                            width:3,
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    pointer: {
                        width:5,
                        shadowColor : '#fff', //默认透明
                        shadowBlur: 5
                    },
                    title : {
                        offsetCenter: [0, '-120%'],       // x, y，单位px
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            // fontWeight: 'bolder',
                            fontStyle: 'italic',
                            color: '#fff',
                            // shadowColor : '#fff', //默认透明
                            shadowBlur: 10,
                            fontSize: 40,
                        },
                        textAlign:'left',
                        padding:10
                    },
                    detail : {
                        //backgroundColor: 'rgba(30,144,255,0.8)',
                       // borderWidth: 1,
                        borderColor: '#fff',
                        shadowColor : '#fff', //默认透明
                        shadowBlur: 5,
                        width: 80,
                        height:30,
                        offsetCenter: [-15, '190%'],       // x, y，单位px
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            fontWeight: 'bolder',
                            color: '#acff48',
                            fontSize: 70
                        }
                    },
                    data:[{value: 326, name: '借书总量'}]
                },
                {
                    name:'还书总量',
                    type:'gauge',
                    center : ['78%', '50%'],    // 默认全局居中
                    radius : '40%',//控制大小
                    startAngle:120,
                    min:700,
                    max:0,
                    splitNumber:7,
                    axisLine: {            // 坐标轴线
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: [[0.29, 'lime'],[0.86, '#1e90ff'],[1, '#ff4500']],
                            width: 2,
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisLabel: {            // 坐标轴小标记
                        textStyle: {       // 属性lineStyle控制线条样式
                            fontWeight: 'bolder',
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    axisTick: {            // 坐标轴小标记
                        length :12,        // 属性length控制线长
                        lineStyle: {       // 属性lineStyle控制线条样式
                            color: 'auto',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    splitLine: {           // 分隔线
                        length :20,         // 属性length控制线长
                        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                            width:3,
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10
                        }
                    },
                    pointer: {
                        width:5,
                        shadowColor : '#fff', //默认透明
                        shadowBlur: 5
                    },
                    title : {
                        offsetCenter: [0, '-120%'],       // x, y，单位px
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            // fontWeight: 'bolder',
                            fontStyle: 'italic',
                            color: '#fff',
                            shadowColor : '#fff', //默认透明
                            shadowBlur: 10,
                            fontSize: 40
                        },
                        textAlign:'right'
                    },
                    detail : {
                        //backgroundColor: 'rgba(30,144,255,0.8)',
                       // borderWidth: 1,
                        borderColor: '#fff',
                        shadowColor : '#fff', //默认透明
                        shadowBlur: 5,
                        width: 80,
                        height:30,
                        offsetCenter: [15, '190%'],       // x, y，单位px
                        textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                            fontWeight: 'bolder',
                            color: '#acff48',
                            fontSize: 70
                        }

                    },
                    data:[{value: 326, name: '还书总量'}]
                }
            ]
        };
        window.onresize = myChart7.resize;

        myChart7.setOption(option);
    }

    function CategoryDisplay() {
        var myChart4 = echarts.init(document.getElementById('chartCategory'));

        // option = {
        //     title: {
        //         text: '阅读指数分析',
        //         textStyle:{
        //             color:"#64879c"
        //         }
        //     },
        //     tooltip: {
        //         trigger: 'item',
        //         formatter: "{a} <br/>{b}: {c} ({d}%)"
        //     },
        //     legend: {
        //         orient: 'vertical',
        //         x: 'left',
        //         textStyle:{
        //             color:"#FFFFFF"
        //         },
        //         data:['其它','书法','绘画技能','中国绘画作品','青年文学','小说','儿童文学','散文']
        //     },
        //     series: [
        //         {
        //             name:'访问来源',
        //             type:'pie',
        //             selectedMode: 'single',
        //             radius: [0, '30%'],

        //             label: {
        //                 normal: {
        //                     position: 'inner'
        //                 }
        //             },
        //             labelLine: {
        //                 normal: {
        //                     show: false
        //                 }
        //             },
        //             data:[
        //                 {value:335, name:'其它'},
        //                 {value:679, name:'艺术', selected:true},
        //                 {value:1548, name:'文学'}
        //             ]
        //         },
        //         {
        //             name:'阅读指数',
        //             type:'pie',
        //             radius: ['34%', '50%'],

        //             data:[
        //                 {value:335, name:'其它'},
        //                 {value:310, name:'书法'},
        //                 {value:234, name:'绘画技能'},
        //                 {value:135, name:'中国绘画作品'},
        //                 {value:1048, name:'青年文学'},
        //                 {value:251, name:'小说'},
        //                 {value:147, name:'儿童文学'},
        //                 {value:102, name:'散文'}
        //             ]
        //         }
        //     ]
        // };

        option = {
            title: {
                text: '阅读指数分析',
                textStyle:{
                    color:"#64879c"
                }
            },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['书法', '绘画技巧','文学','艺术','其它'],
                top: 'bottom',
                left: 'center',
                textStyle:{
                    color:"#ffffff"
                }
            },
            grid: {
                left: '3%',
                containLabel: true
            },
            xAxis:  {
                type: 'value',
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置图形右侧颜色
                    }
                }
            },
            yAxis: {
                type: 'category',
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置图形右侧颜色
                    }
                },
                data: ['周一','周二','周三','周四','周五','周六','周日']
            },
            series: [
                {
                    name: '书法',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [320, 302, 301, 334, 390, 330, 320]
                },
                {
                    name: '绘画技巧',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: '文学',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: '艺术',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [150, 212, 201, 154, 190, 330, 410]
                },
                {
                    name: '其它',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [820, 832, 901, 934, 1290, 1330, 1320]
                }
            ]
        };
        myChart4.setOption(option);
    }

    function getLastDay(year,month) {
        var new_year = year;    //取当前的年份
        var new_month = month++;//取下一个月的第一天，方便计算（最后一天不固定）
        if(month>12) {
            new_month -=12;        //月份减
            new_year++;            //年份增
        }
        var new_date = new Date(new_year,new_month,1);                //取当年当月中的第一天
        return (new Date(new_date.getTime()-1000*60*60*24)).getDate();//获取当月最后一天日期
    }
    //入馆人数柱状图 4
    function FlowCount() {
        var myChart = echarts.init(document.getElementById('flowchart'));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: '入馆人次',
                textStyle:{
                    color:"#64879c"
                }
            },
            tooltip: {},
            legend: {
                bottom:0,
                data:['入馆人次'],
                show:true,
                textStyle:{
                    color:"#FFFFFF"
                }
            },
            xAxis: {
                axisLine:{
                    lineStyle:{
                        color:'#95a7c5'
                    }
                },
                axisLabel:{
                    rotate: 40,
                    interval:'0',
                    // textStyle:{
                    //     color:'#FFFFFF'
                    // }
                },
                data: ["04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12","04-13","04-14","04-15","04-16","04-17","04-18","04-19","04-20","04-21","04-22","04-23","04-24","04-25","04-26","04-27","04-28","04-29","04-30"]
            },
            yAxis: {
                axisLine: {
                    lineStyle: {
                        color: '#95a7c5'//设置x轴颜色
                    }
                },
                axisLabel: {
                    formatter:'{value}k',
                    // textStyle: {
                    //     color: '#FFFFFF'
                    // }
                }
            },
            series: [{
                itemStyle:{
                    normal:{
                        color:"#4fc0f5"
                    }
                },
                name: '入馆人次',
                type: 'bar',
                data: [1, 2, 3, 10, 10, 20,0,0,1, 2, 3, 10, 10, 20,0,0,1, 2, 3, 10, 10, 20,0,0,1, 2, 3, 10, 10, 20]
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    //上月人数统计 4
    function GetMJLastMonthFlow() {
        var et = window.localStorage["et"];
        var backServerUrl = window.localStorage["backServerUrl"];
        var year = new Date().format("yyyy");
        var month = new Date().format("MM");
        if(month == "01"){
          year--;
          month = "12";
        }
        else{
          month--;
        }
        var startTime = year + "-" + month + "-01";
        var endTime = year + "-" + month + "-" + getLastDay(year, month);
        var limit = 10;
        $.ajax({
            type: "get",
            url: backServerUrl + "api/statistics/mjflow?aggregation=total&start=" + startTime + "T00:00:01.001&end=" + endTime + "T23:59:59.001",
            dataType: "json",
            headers: {'Content-Type': 'application/json', 'Authorization': et},
            success: function (data) {
                // alert(JSON.stringify(data));
                if(data !== undefined){
                    var enterCount = data.in
                    $("#lastMonthCcout").html(enterCount);
                }
            }
        });
    }
    //获取天气 2
    function GetWeather() {
        $.ajax({
            type: "get",
            url: "http://i.tianqi.com/index.php?c=code&id=83&py=beijing",
            dataType: "jsonp",
            success: function (data) {
                // alert(JSON.stringify(data));
            }
        });
    }

    function UpdateBigScreen() {
        // var rootPath = getRootPath();
        // var backServerUrl = "";
        // if(rootPath.substring(7,10) == "192" || rootPath.substring(7,10) == "loc" || rootPath.substring(7,10) == "10.") {
        //    backServerUrl = "http://1.30.233.74:10000/";    //包头
        //    //backServerUrl = "http://10.232.2.51:10000/";    //包头内网
        // }
        // else
        // {
        //     backServerUrl = "http://1.30.233.74:10000/";
        // }
        // window.localStorage["backServerUrl"] = backServerUrl;
        // $.ajax({
        //     type: "POST",
        //     url: backServerUrl + "api/auth/token",
        //     dataType: "json",
        //     headers: {'Content-Type': 'application/json'},
        //     data:JSON.stringify({"username": "shrfid", "password":"111"}),
        //     success: function (data) {
        //         var last=(data.token).toString();
        //         // console.log(last);
        //         window.localStorage["et"] = "Bearer " + last;
        //         BorrowCount();
        //         BRDisplay();
        //         BRDisplay2();
        //         // borrow();
        //         InforShow();
        //         // ReaderCount();
        //         // GetMJWarn();
        //         // GetMJFlow();
        //         // GetMJLastMonthFlow();
        //         // BRCount();
        //         // FlowCount();
        //         CategoryDisplay();
        //         var weather = '<iframe id="weather" name="weather_inc" src="http://i.tianqi.com/index.php?c=code&id=83&py=beijing" width="515" height="178" allowtransparency="true" style="background-color: transparent;" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
        //         $("#area2").html(weather);
        //     },
        //     error: function (XMLHttpRequest, textStatus, errorThrown) {
        //         //当前状态(readyState),0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成
        //         console.log("Token 请求产生错误!\n" + "status = " + XMLHttpRequest.status + "\nstatusText = " + XMLHttpRequest.statusText + "\nreadyState = " + XMLHttpRequest.readyState + "\nresponseText = " + XMLHttpRequest.responseText);
        //     }
        // });
                BorrowCount();
                BRDisplay();
                BRDisplay2();
                // borrow();
                InforShow();
                CategoryDisplay();
    }

    function Slide() {
        slideImagesSrc = [];
        slideImagesSrc.push("book_mao.jpg");
        slideImagesSrc.push("book_3t.jpg");
        slideImagesSrc.push("book_lzyz.jpg");
        slideImagesSrc.push("book_etwx.jpg");
        $("#imgmain").attr("src", slideImagesSrc.get(0));
    }

    function InitPage() {
        $("div[id^=area]").css("border","0px solid blue");
        UpdateBigScreen();
        if(setIntervalID === 0)
            setIntervalID = setInterval("bigscreen.UpdateBigScreen()",5000);
    }

    return{
        InitPage : InitPage,
        UpdateBigScreen : UpdateBigScreen
    }
}();
